package com.legendshop.openportal.sdk.service;

import cn.hutool.core.lang.TypeReference;
import com.legendshop.openportal.sdk.model.OpenResult;
import com.legendshop.openportal.sdk.model.request.*;
import com.legendshop.openportal.sdk.model.response.AddressParseResult;

import java.util.Map;

/**
 * @Description: 开放平台地址服务
 * @Author lwj
 * @data 2024/6/19
 **/
public class LocationService extends BaseService {

    /**
     * 获取一级地址
     *
     * @param request
     * @return
     */
    public static OpenResult<Map<String,String>> getProvince(GetProvinceRequest request) {
        return execute(request, new TypeReference<Map<String, String>>() {});
    }

    /**
     * 获取二级地址
     *
     * @param request
     * @return
     */
    public static OpenResult<Map<String,String>> getCity(GetCityRequest request) {
        return execute(request, new TypeReference<Map<String, String>>() {});
    }

    /**
     * 获取三级地址
     *
     * @param request
     * @return
     */
    public static OpenResult<Map<String,String>> getArea(GetAreaRequest request) {
        return execute(request, new TypeReference<Map<String, String>>() {});
    }


    /**
     * 获取四级地址
     *
     * @param request
     * @return
     */
    public static OpenResult<Map<String,String>> getTown(GetTownRequest request) {
        return execute(request, new TypeReference<Map<String, String>>() {});
    }

    /**
     * 校验地址合法性
     * @param checkAreaRequest
     * @return
     */
    public static OpenResult<Void> checkArea(CheckAreaRequest checkAreaRequest){
        return execute(checkAreaRequest, Void.class);
    }

    /**
     * 智能解析地址
     * @param request
     * @return
     */
    public static OpenResult<AddressParseResult> addressParse(AddressParseRequest request){
        return execute(request, AddressParseResult.class);
    }

}
